﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;

namespace DAL
{
    public class LoginDAL
    {
#pragma warning disable CS0618 // “ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings”
        string conn = ConfigurationSettings.AppSettings["con"].ToString();
#pragma warning restore CS0618 // “ConfigurationSettings.AppSettings”已过时:“This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings”

        //验证管理员账号密码
        public int verify(string username,string password)
        {
            SqlParameter[] sp = new SqlParameter[]{
                new SqlParameter("@username",username),
                new SqlParameter("@password",password)
            };
            string sqlstr = "select count(*) from qx where username = @username and password = @password";
            try
            {
                int i = Int32.Parse(SqlHelper.ExecuteScalar(conn, CommandType.Text, sqlstr, sp).ToString());
                return i;
            }
            catch (Exception)
            {

                return -1;
            }
        }
        /// <summary>
        /// 检查系统版本为脱机还是联机
        /// </summary>
        /// <returns></returns>
        public int isOnline()
        {
            SqlParameter[] sp = new SqlParameter[]{
            };
            string sqlstr = "select isnull(isonline,'') from systemset";
            try
            {
                int i = Int32.Parse(SqlHelper.ExecuteScalar(conn, CommandType.Text, sqlstr, sp).ToString());
                return i;
            }
            catch (Exception)
            {

                return -1;
            }
        }
    }
}
